# ----------------------------------------------------------------------
# ' this file uses therapeutic medical claims files for each quarter
# ' to generate a list of patients taking pain therapy in each quarter
# ' by BK (bl11@indiana.edu)
# ----------------------------------------------------------------------

load_library = c('bit64','data.table','fst','future.apply','stringr','logger')
invisible(lapply(load_library, function(x) library(x, character.only=TRUE, quietly= TRUE)))
options(scipen=999)

bucket = file.path('/N','project','iuni_doctorshopping')

# read arguments
args=commandArgs(TRUE)
infile = args[[1]]
outfile = args[[2]]

data = fread(infile)

# make a unique list
udata = data[,.(
	n_claims = .N
	), by=c('PATID','PROC_CD')]

fwrite(udata, outfile)



